<template>
  <div>
    <div class="temp_plate print-wrap-58 print-wrap-normal"
      style="width: 58mm;font-size: 12px;
        padding: 10px;
        border: 1px solid #a5a5a5;
        box-shadow: 2px 2px 2px #d3d3d3;text-align: left;"
    >
      <h2 style="text-align:center; ">
        <span>{{ info ? info.peopleEntity.prices.sellerName : '酒店' }}</span>
        登记单
      </h2>
      <p class="panelone panelone2">
        <span>打印时间:</span>
        <span>{{ nowDate + ' ' + nowTime + ' ' }}</span>
        <span>打印人:</span>
        <span>{{ user ? user.username : '易信' }}</span>
      </p>
      <p class="panelone panelone2" style="margin-bottom: 5px;">
        <span>单号:</span>
        <span>{{ info ? info.singleEntity.sysNo : 'R201909010001' }}</span>
        <span>登记人:</span>
        <span>{{ user ? user.username : '易信' }}</span>
      </p>

      <table style="font-size:13px; border:1px solid #000;text-align: center; border-collapse: collapse; padding:2px;width:100%">
        <tr>
          <td style="border:1px solid #000;" colspan="2">
            <span>{{ info ? info.roomEntity.name : '大床房' }}</span>
          </td>
          <td style="border:1px solid #000;" colspan="2">
            <span>房价:{{ info ? (priceMap[today] ? priceMap[today] : currData) : '198' }}</span>
          </td>
        </tr>
        <tr>
          <td style="border:1px solid #000;" colspan="2">
            <span>
              入住时间:
              <br />
              {{ info ? info.singleEntity.arrivalsTime : '2019-09-02 02:00' }}
            </span>
          </td>
          <td style="border:1px solid #000;" colspan="2">
            <span>
              预离时间:
              <br />
              {{ info ? info.singleEntity.predissociationTime : '2019-09-03 02:00' }}
            </span>
          </td>
        </tr>
        <tr>
          <td style="border:1px solid #000;" colspan="2"><span>早餐:无</span></td>
          <td style="border:1px solid #000;" colspan="2">
            <span v-if="info">
              客人押金: {{info.peopleEntity.deposit}}
            </span>
            <span v-else>
              客人押金: 无
            </span>
          </td>
        </tr>
        <tr>
          <td colspan="4" style="border:1px solid #000;">
            <span>
              来源:
              <span v-if="info">
                <span v-if="info.singleEntity.sourceType == 0">门店</span>
                <span v-if="info.singleEntity.sourceType == 1">会员</span>
                <span v-if="info.singleEntity.sourceType == 2">协议单位</span>
                <span v-if="info.singleEntity.sourceType == 2">中介</span>
              </span>
              <span v-else>上门散客</span>
            </span>
          </td>
        </tr>
        <tr>
          <td style="border:1px solid #000;" colspan="2"><span>其他服务: 无</span></td>
          <td style="border:1px solid #000;" colspan="2">
            <span>门卡:</span>
            <span>0</span>
          </td>
        </tr>

        <tr>
          <td style="border:1px solid #000;">客人姓名</td>
          <td style="border:1px solid #000;">性别</td>
          <td style="border:1px solid #000;">生日</td>
          <td style="border:1px solid #000;">证件</td>
        </tr>
        <tr>
          <td style="border:1px solid #000;">{{ info ? info.peopleEntity.name : '貂蝉' }}</td>
          <td style="border:1px solid #000;">
            <p v-if="info">
              <span v-if="info.peopleEntity.sex == 1">男</span>
              <span v-else>女</span>
            </p>
            <p v-else>女</p>
          </td>
          <td style="border:1px solid #000;">
            <p v-if="info">
              <span v-if="info.peopleEntity.birthday">{{ info.peopleEntity.birthday }}</span>
              <span v-else>暂无</span>
            </p>
            <p v-else>2019-10-09</p>
          </td>
          <td style="border:1px solid #000;">
            <span v-if="info">
              <span v-if="info.peopleEntity.type == 0">居民身份证</span>
              <span v-if="info.peopleEntity.type == 1">户口簿</span>
              <span v-if="info.peopleEntity.type == 2">军官证</span>
              <span v-if="info.peopleEntity.type == 3">警官证</span>
              <span v-if="info.peopleEntity.type == 4">士兵证</span>
              <span v-if="info.peopleEntity.type == 5">护照</span>
              <span v-if="info.peopleEntity.type == 6">其他</span>
              <span v-if="info.peopleEntity.certificatesNumber">{{ info.peopleEntity.certificatesNumber }}</span>
              <span v-else>暂无</span>
            </span>
            <span v-else>
              护照
              <br />
              44546131457814
            </span>
          </td>
        </tr>
      </table>

      <div style="margin-left:10px;">
        <div style="width:90%;"><div v-html="note"></div></div>
      </div>
      <div style="font-weight:bold;font-size:16px;margin-top:3px; ">
        <span class="signtext" style="width:40%;">确定签字:</span>
        <span style="width:55%;" class="inputspan"></span>
      </div>
    </div>
  </div>
</template>

<script>
import moment from 'moment';
export default {
  props: ['note', 'info', 'priceMap', 'currData'],
  data() {
    return {
      nowDate: '', // 当前日期
      nowTime: '', // 当前时间
      nowWeek: '', // 当前星期
      today: moment().format('YYYY-MM-DD'),
      user: {}
    };
  },
  methods: {
    currentTime() {
      setInterval(this.getDate, 500);
    },
    getUser() {
      this.$http({
        url: this.$http.adornUrl(`/hotel/thotelprinttemplate/printInfo`),
        method: 'get'
      }).then(({ data }) => {
        if (data.code === 0) {
          this.user = data.user;
        }
      });
    },
    getDate: function() {
      var _this = this;
      let yy = new Date().getFullYear();
      let mm = new Date().getMonth() + 1;
      let dd = new Date().getDate();
      let week = new Date().getDay();
      let hh = new Date().getHours();
      let mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes();
      if (week == 1) {
        this.nowWeek = '星期一';
      } else if (week == 2) {
        this.nowWeek = '星期二';
      } else if (week == 3) {
        this.nowWeek = '星期三';
      } else if (week == 4) {
        this.nowWeek = '星期四';
      } else if (week == 5) {
        this.nowWeek = '星期五';
      } else if (week == 6) {
        this.nowWeek = '星期六';
      } else {
        this.nowWeek = '星期日';
      }
      _this.nowTime = hh + ':' + mf;
      _this.nowDate = yy + '/' + mm + '/' + dd;
    }
  },
  mounted() {
    this.currentTime();
    if (this.info) {
      if(this.currData){
        this.currData = this.priceMap[moment(this.info.peopleEntity.arrivalsTime).format('YYYY-MM-DD')];
      }
      
    }
    this.getUser();
  }
};
</script>

<style lang="scss">
</style>
